package com.wltt.product.frfront.controller;

import com.wltt.product.frfront.model.ResultData;
import com.wltt.product.frfront.model.vo.FormulaDetailREQ;
import com.wltt.product.frfront.model.vo.UpdateFormulaREQ;
import com.wltt.product.frfront.service.FormulaService;
import jakarta.annotation.Resource;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/api/formula")
public class FormulaController {

    private static final Logger logger = LogManager.getLogger(FormulaController.class);

    @Resource
    private FormulaService formulaService;

    /**
     * 查询所有配方
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/allFormula"}, method = RequestMethod.POST)
    public ResultData allFormula() {
        return formulaService.allFormula();
    }

    /**
     * 查询所有配方用于下拉选
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/allFormulaForSelect"}, method = RequestMethod.POST)
    public ResultData allFormulaForSelect() {
        return formulaService.allFormulaForSelect();
    }

    /**
     * 配方详情
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/formulaDetail"}, method = RequestMethod.POST)
    public ResultData formulaDetail(@RequestBody FormulaDetailREQ formulaDetailREQ) {
        return formulaService.formulaDetail(formulaDetailREQ);
    }

    /**
     * 更新配方
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = {"/updateFormula"}, method = RequestMethod.POST)
    public ResultData updateFormula(@RequestBody UpdateFormulaREQ updateFormulaREQ) {
        return formulaService.updateFormula(updateFormulaREQ);
    }

}
